package com.nameli.SIM.util;

import org.junit.platform.commons.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author NAME-L
 * @Description token工具类
 * @className TokenUtil
 * @date 2021-12-31 16:25:37
 */
public class TokenUtil {

    /**
     * 获取请求的token
     */
    public static String getRequestToken(HttpServletRequest httpRequest) {
        //从header中获取token
        String token = httpRequest.getHeader("token");
        //如果header中不存在token，则从参数中获取token
        if (StringUtils.isBlank(token)) {
            token = httpRequest.getParameter("token");
        }
        return token;
    }

}
